<template>
  <div class="nav-header">
    <!-- <el-icon class="fold-menu" @click="handleFoldClick"><Fold /></el-icon> -->
    <Fold
      style="width: 1em; height: 1em; margin-right: 8px"
      class="fold-menu"
      @click="handleFoldClick"
    />
    <div class="content">
      <DlBreadcrumb :breadcrumbs="breadcrumbs" />
      <UserInfo />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from "vue";
import UserInfo from "./user-info.vue";
import DlBreadcrumb, { IBreadcrumb } from "@/base-ui/bread";
import { pathMapBreadcrumbs } from "@/utils/map-menus";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
export default defineComponent({
  emits: ["foldChange"],
  components: {
    UserInfo,
    DlBreadcrumb,
  },
  setup(props, { emit }) {
    const isFold = ref(false);
    //面包屑数据
    const breadcrumbs = computed(() => {
      const store = useStore();
      const userMenus = store.state.login.userMenus;
      const route = useRoute();
      const currentPath = route.path;
      return pathMapBreadcrumbs(userMenus, currentPath);
    });
    const handleFoldClick = () => {
      isFold.value = !isFold.value;
      emit("foldChange", isFold.value);
    };
    return {
      isFold,
      breadcrumbs,
      handleFoldClick,
    };
  },
});
</script>

<style scoped lang="less">
.nav-header {
  display: flex;
  width: 100%;
  .fold-menu {
    font-size: 30px;
    cursor: pointer;
  }
  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 20px;
    cursor: pointer;
  }
}
</style>
